import Global from 'system.global'

const globalData = Global();


function isPhone(){
    return navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)!=null;
}
globalData.isPhone = isPhone();

function required(call:(isPhone:boolean)=>void){
    let handle: number|null = null;
    if(globalData.isPhone){
        //移动端
        handle =  setInterval(()=>{
            if(globalData.ydui!=null){
                handle&&window.clearInterval(handle);
                call(true);
            }
        },100);
        
    }else{
        //PC端
        handle =  setInterval(()=>{
            if(globalData.Element!=null){
                handle&&window.clearInterval(handle);
                call(false);
            }
        },100);
    }
}
export {
    required
}